package com.nyz.huawei.vod.client;

import com.external.system.vo.coalmine.HwVodCredentialVo;
import com.huawei.vod.model.asset.QueryAssetDetailRsp;
import com.huawei.vod.model.asset.QueryAssetListRsp;
import com.nyz.huawei.model.*;
import com.nyz.huawei.obs.config.ObsConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class VodClient {

    private VodConfig vodConfig;
    private ObsConfig obsConfig;


//    private com.huaweicloud.sdk.vod.v1.VodClient getClient(HwVodCredentialVo param) {
//        ICredential auth = new BasicCredentials()
//                .withAk(param.getAccess())
//                .withSk(param.getSecret()).withProjectId(vodConfig.getProjectId()).withSecurityToken(param.getSecuritytoken());
//
//        com.huaweicloud.sdk.vod.v1.VodClient client = com.huaweicloud.sdk.vod.v1.VodClient.newBuilder()
//                .withCredential(auth)
//                .withRegion(VodRegion.valueOf("cn-north-4"))
//                .build();
//        return client;
//    }
//
//    public TemporaryCredential requestTemporaryCredential(String obsusername, String sdym2019, String hw048455102, int i) {
//
//        return new TemporaryCredential(obsusername, sdym2019, hw048455102, i);
//    }

//    public static uploadVideo uploadVideo(VideoUploadServiceImpl.UploadVideoRequest request) {
//        return new uploadVideo() ;
//    }

//    public UploadAssetRsp createAssetByFile(CreateAssetByFileReq req, HwVodCredentialVo param) {
//        com.huaweicloud.sdk.vod.v1.VodClient client = getClient(param);
//
//        CreateAssetByFileUploadRequest request = new CreateAssetByFileUploadRequest();
//        CreateAssetByFileUploadReq body = new CreateAssetByFileUploadReq();
//        body.setTitle(req.getTitle());
//        body.setVideoName(req.getVideoName());
//        body.setVideoType(req.getVideoType());
//        body.setCategoryId(req.getCategoryId());
//
//        request.withBody(body);
//        try {
//            CreateAssetByFileUploadResponse response = client.createAssetByFileUpload(request);
//            System.out.println(response.toString());
//        } catch (ConnectionException e) {
//            e.printStackTrace();
//        } catch (RequestTimeoutException e) {
//            e.printStackTrace();
//        } catch (ServiceResponseException e) {
//            e.printStackTrace();
//            System.out.println(e.getHttpStatusCode());
//            System.out.println(e.getRequestId());
//            System.out.println(e.getErrorCode());
//            System.out.println(e.getErrorMsg());
//        }
//
//        return new UploadAssetRsp();
//    }

    public ConfirmAssetUploadRsp confirmAssetUpload(ConfirmAssetUploadReq req) {
        return new ConfirmAssetUploadRsp();
    }

    public UpdateAssetMetaReq updateAssetMeta(UpdateAssetMetaReq updateAssetMetaReq) {
        return null;
    }

    public DeleteAssetRsp deleteAssets(DeleteAssetReq deleteAssetReq) {
        return null;
    }

    public QueryAssetDetailRsp queryAssetDetail(QueryAssetDetailReq queryAssetDetailReq) {
        return null;
    }

//    public ShowAssetCipherResponse queryCipher(QueryCipherReq queryCipherReq) {
//        return null;
//    }
//
//    public CreateAssetCategoryResponse createAssetCategory(CreateCategoryReq req, HwVodCredentialVo param) {
//        com.huaweicloud.sdk.vod.v1.VodClient client = getClient(param);
//
//        CreateAssetCategoryRequest request = new CreateAssetCategoryRequest();
//        com.huaweicloud.sdk.vod.v1.model.CreateCategoryReq body = new com.huaweicloud.sdk.vod.v1.model.CreateCategoryReq();
//        body.setName(req.getName());
//        request.withBody(body);
//        try {
//            CreateAssetCategoryResponse response = client.createAssetCategory(request);
//            System.out.println(response.toString());
//            return response;
//        } catch (ConnectionException e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        } catch (RequestTimeoutException e) {
//            e.printStackTrace();
//        } catch (ServiceResponseException e) {
//            throw new RuntimeException(e.getErrorMsg());
//        }
//        return null;
//    }

    public QueryAssetListRsp queryAssetList(QueryAssetListReq queryAssetListReq) {
        return null;
    }

    public BaseResponse deleteAssetCategory(Integer categoryId, HwVodCredentialVo param) {
//        com.huaweicloud.sdk.vod.v1.VodClient client = getClient(param);
//
//        DeleteAssetCategoryRequest request = new DeleteAssetCategoryRequest();
//        request.setId(categoryId);
//        try {
//            DeleteAssetCategoryResponse response = client.deleteAssetCategory(request);
//            System.out.println(response.toString());
//            return new BaseResponse();
//        } catch (ConnectionException e) {
//            e.printStackTrace();
//        } catch (RequestTimeoutException e) {
//            e.printStackTrace();
//        } catch (ServiceResponseException e) {
//            e.printStackTrace();
//            System.out.println(e.getHttpStatusCode());
//            System.out.println(e.getRequestId());
//            System.out.println(e.getErrorCode());
//            System.out.println(e.getErrorMsg());
//        }
        return null;
    }

    public BaseResponse modifyAssetCategory(EditCategoryReq editCategoryReq, HwVodCredentialVo param) {
//        com.huaweicloud.sdk.vod.v1.VodClient client = getClient(param);
//        UpdateAssetCategoryRequest request = new UpdateAssetCategoryRequest();
//        UpdateCategoryReq body = new UpdateCategoryReq();
//        body.setName(editCategoryReq.getName());
//        body.setId(editCategoryReq.getId());
//        request.withBody(body);
//        try {
//            UpdateAssetCategoryResponse response = client.updateAssetCategory(request);
//            System.out.println(response.toString());
//            return new BaseResponse();
//        } catch (ConnectionException e) {
//            e.printStackTrace();
//        } catch (RequestTimeoutException e) {
//            e.printStackTrace();
//        } catch (ServiceResponseException e) {
//            e.printStackTrace();
//            System.out.println(e.getHttpStatusCode());
//            System.out.println(e.getRequestId());
//            System.out.println(e.getErrorCode());
//            System.out.println(e.getErrorMsg());
//        }
        return null;
    }

    //public static class uploadVideo {


    public int getCode() {
        return 0;
    }

    public String getVideoUrl() {
        return null;
    }
}
//    //上传视频方法实现
//    private CreateAssetByFileUploadResponse createAssetByFileUpload(CreateAssetByFileUploadRequest request) {
//
//        return null;
//    }
//}
